const path = require('path')

const HtmlPlugin = require('html-webpack-plugin');
const htmlPlugin = new HtmlPlugin({
    template: './src/index1.html',
    filename: './index.html'

});
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const cleanWebpack = new CleanWebpackPlugin();
module.exports = {
    //production development
    mode: 'development',
    devtool: 'nosources-source-map',
    //指明引入那些插件
    plugins: [htmlPlugin, cleanWebpack],
    //指定要处理那个文件
    entry: path.join(__dirname, "./src/index.js"),
    //指定文件生成到那个位置
    output: {
        path: path.join(__dirname, './dist'),
        filename: 'js/main.js'
    },
    //所有第三方文件模块等匹配规则
    module: {
        // 文件后缀名的匹配规则
        rules: [
            { test: /\.css$/, use: ['style-loader', 'css-loader', 'less-loader'] },
            //匹配配置图片路径加载问题
            { test: /\.png|jpg$/, use: 'url-loader?limit=110&outputPath=img' }
        ]
    },
    devServer: {
        static: {
            directory: __dirname
        },
        open: true,
        port: 8089,
        host: '127.0.0.1'
    }
}